<template>
  <div class="container">
    <div @click="toIndex">路由跳转</div>
    <div @click="toIndex">全局工具类：{{ $util.getNow() }}</div>
    <div>全局样式：{{ time }}</div>
    <div>自定义图标： <span class="iconfont icon-a-38"></span></div>
    <div @click="login">post请求body参数（登录）</div>
    <div @click="getPath">get请求path参数</div>
    <div @click="getQuery">get请求query参数</div>
  </div>
</template>

<script>
import { login, getArticleList, getDictList } from '@/api/demo/demo'
export default {
  name: 'login',
  data() {
    return {
      time: ''
    }
  },
  mounted() {
    setInterval(() => {
      this.time = this.$util.getNow('time')
    })
  },
  methods: {
    toIndex() {
      this.$router.push('/index')
    },
    login() {
      let param = {
        username: 'admin',
        password: 'jixingkeji@1234',
        from: 2
      }
      login(param).then(res => {
        // 存储用户信息、token信息、字典信息（localStorage/sessionStorage）
        sessionStorage.setItem('token', res.token)
        sessionStorage.setItem('userInfo', JSON.stringify({}))
        sessionStorage.setItem('dictionary', JSON.stringify({}))
      })
    },
    getPath() {
      let param = {
        dictType: 'feedback_type'
      }
      getDictList(param).then(res => {
        console.log(res)
      })
    },
    getQuery() {
      let param = {
        pageNum: 1,
        pageSize: 10,
        articleCategoryId: 10
      }
      getArticleList(param).then(res => {
        console.log(res)
      })
    }
  }
}
</script>

<style scoped></style>
